package org.daochong.lang;

import java.text.SimpleDateFormat;
import java.util.Date;

public class SystemLogger {

	public static void logger(String message) {
		StackTraceElement caller = BeanUtil.getCallerInfo();
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
		System.out.println(sdf.format(new Date()) + " " + caller.getClassName() + " " + caller.getMethodName()
				+ "(line:" + caller.getLineNumber() + ")");
		System.out.println(message);
	}

	public static void info(String prefix, String message) {
		logger(prefix + ": " + message);
	}

	public static void info(String message) {
		logger("信息: " + message);
	}

	public static void error(String message) {
		logger("错误: " + message);
	}

	public static void error(String message, Throwable e) {
		logger("错误: " + message);
		e.printStackTrace();
	}
}
